LicenseManager
@objc(LSLicenseManager)
final class LicenseManager : BaseManager
extension LicenseManager : CVarArg, CustomDebugStringConvertible, CustomStringConvertible, Equatable, Hashable, NSObjectProtocol
Entry point to the LicenseSpring SDK Use to obtain the license or common product information
-
Init LicenseManager with configuration
Throws
LSErrorif input configuration is wrongDeclaration
Swift
override init(configuration: Configuration) throwsParameters
configurationConfiguration of LicenseManager
-
Activated License or nil if no license is active.
Declaration
Swift
@objc var currentLicense: License? { get } -
Activate the license using a license key asynchronously.
Declaration
Swift
@objc func activateLicense(licenseKey: String, completion: @escaping (License?, (any Error)?) -> Void) -
Activate the license using user and password.
Throws
Error if license activation fails. May be ofLSErrortype.Declaration
Swift
@objc func activateLicense(user: String, password: String) throws -> LicenseParameters
userUser ID, typically email in lowercase.
passwordUser’s password.
Return Value
Activated license.
-
Activate the license using user and password asynchronously.
Declaration
Swift
@objc func activateLicense(user: String, password: String, completion: @escaping (License?, (any Error)?) -> Void) -
Activate the license using serverId.
Throws
Error if license activation fails. May be ofLSErrortype.Declaration
Swift
@objc func activateLicense(user: String, password: String, serverId: Int64) throws -> LicenseParameters
userUser ID, typically email in lowercase.
passwordUser’s password.
Return Value
Activated license.
-
Activate the license using user, password, and server ID asynchronously.
Declaration
Swift
@objc func activateLicense(user: String, password: String, serverId: Int64, completion: @escaping (License?, (any Error)?) -> Void)Parameters
userUser ID, typically email in lowercase.
passwordUser’s password.
serverIdLicense ID, typically a 64-bit ID.
completion -
Activate the license using license activation response file.
Throws
Error if license activation fails. May be ofLSErrortype.Declaration
Swift
@objc func activateLicenseOffline(_ activationResponseFile: URL) throws -> LicenseParameters
activationResponseFileActivation response file location.
Return Value
Activated license.
-
Activate the license using license activation response file asynchronously.
Declaration
Swift
@objc func activateLicenseOffline(_ activationResponseFile: URL, completion: @escaping (License?, (any Error)?) -> Void) -
Creates offline activation file request.
Throws
Error if create activation file fails. May be ofLSErrortype.Declaration
Swift
@objc func createOfflineActivationFile(licenseKey: String, preferredLocation: URL? = nil) throws -> URLParameters
licenseKeyLicense key to be activated offline.
preferredLocationOptional custom activation request file location. ‘~/Desktop/ls_activation.req’ by default.
Return Value
Location of offline activation file request.
-
Creates offline activation file request.
Throws
Error if create activation file fails. May be ofLSErrortype.Declaration
Swift
@objc func createOfflineActivationFile(user: String, password: String, preferredLocation: URL? = nil, serverID: Int64 = 0) throws -> URLParameters
userUser ID, typically email in lowercase.
passwordUser’s password.
preferredLocationOptional custom activation request file location. ‘~/Desktop/ls_activation.req’ by default.
serverIDserverID, server-side license identifier, typically 64-bit id.
Return Value
Location of offline activation file request.
-
Get Activation code for air gap activation.
Throws
Error if generation fails. May be ofLSErrortype.Declaration
Swift
@available(macOS, introduced: 10.15) @available(iOS, introduced: 13.0) @objc func generateAirGapActivationCode(initializationCode: String, licenseKey: String) throws -> StringParameters
initializationCodeCode received from the air gap activation portal.
licenseKeyLicense key of air gap license.
Return Value
Air gap Activation code. Empty string in case of error.
-
Verify Confirmation code for air gap activation.
Throws
Error if verification fails. May be ofLSErrortype.Declaration
Swift
@available(macOS, introduced: 10.15) @available(iOS, introduced: 13.0) @objc func verifyAirGapConfirmationCode(confirmationCode: String, licenseKey: String, policyID: Int) throwsParameters
confirmationCodeCode received from the air gap activation portal.
licenseKeyLicense key of air gap license.
policyIDPolicy id received from the air gap activation portal.
-
Activate air gap license using policy file.
Throws
Error if activation fails. May be ofLSErrortype.Declaration
Swift
@objc func activateLicense(airgapPolicyFile policyFile: URL, licenseKey: String, policyID: Int) throws -> LicenseParameters
licenseKeyLicense key.
policyIDId of the license policy.
Return Value
License if activation succeeded.
-
Activate air gap license using policy file asynchronously.
Declaration
Swift
@objc func activateLicense(airgapPolicyFile policyFile: URL, licenseKey: String, policyID: Int, completion: @escaping (License?, (any Error)?) -> Void) -
Retrieve URL for Single Sign-On license activation.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestSSOURL() throws -> URLReturn Value
URL for Single Sign-On.
-
Retrieve URL for Single Sign-On license activation.
- completion: URL for Single Sign-On if request succeeds, Error if request fails. May be of
LSErrortype.
Declaration
Swift
@objc func requestSSOURL(completion: @escaping (URL?, (any Error)?) -> Void)Parameters
completionURL for Single Sign-On if request succeeds, Error if request fails. May be of
LSErrortype. - completion: URL for Single Sign-On if request succeeds, Error if request fails. May be of
-
Activate the license using SSO token asynchronously.
Declaration
Swift
@objc func activateLicense(ssoToken: String, completion: @escaping (License?, (any Error)?) -> Void) -
Request trial license from LicenseSpring platform.
Throws
Error if request fails. May be ofLSErrortype.Note
Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.Declaration
Swift
@objc func requestTrialKey(with email: String?) throws -> StringReturn Value
Trial license key or user email in case of user-based product.
-
Request trial license from LicenseSpring platform.
Throws
Error if request fails. May be ofLSErrortype.Note
Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.Declaration
Swift
@objc func requestTrialKey(for customer: Customer?, licensePolicy: String? = nil) throws -> StringParameters
licensePolicyLicense policy code. If nil, the default license policy for the product will be used.
Return Value
Trial license key or user email in case of user-based product.
-
Request trial license from LicenseSpring platform.
Note
Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.Declaration
Swift
@objc func requestTrialKey(with email: String?, completion: @escaping (String?, (any Error)?) -> Void)Parameters
completionTrial license key or user email in case of user-based product if request succeeds, Error if request fails. May be of
LSErrortype. -
Request all available versions for the license user.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestAvailableVersions(licenseKey: String, env: String? = nil) throws -> [AvailableVersion]Parameters
licenseKeyLicense key.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
Return Value
An array of versions available for the license.
-
Request all available versions for the license user.
Declaration
Swift
@objc func requestAvailableVersions(licenseKey: String, env: String? = nil, completion: @escaping ([AvailableVersion]?, (any Error)?) -> Void)Parameters
licenseKeyLicense key.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
completionAn array of versions available for the license if request succeeds, Error if request fails. May be of
LSErrortype. -
Request all available versions for the license user.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestAvailableVersions(user: String, env: String? = nil) throws -> [AvailableVersion]Parameters
userLicense user name, usually email in lowercase.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
Return Value
An array of versions available for the license.
-
Request all available versions for the license user.
Declaration
Swift
@objc func requestAvailableVersions(user: String, env: String? = nil, completion: @escaping ([AvailableVersion]?, (any Error)?) -> Void)Parameters
userLicense user name, usually email in lowercase.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
completionAn array of versions available for the license if request succeeds, Error if request fails. May be of
LSErrortype. -
Request installation information for the license.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestInstallationFile(licenseKey: String, version: String? = nil, env: String? = nil) throws -> InstallationFileParameters
licenseKeyLicense key.
versionDesired product (app) version, optional. If not provided, the last available version assumed.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
Return Value
Installation information related to the license.
-
Request installation information for the license.
Declaration
Swift
@objc func requestInstallationFile(licenseKey: String, version: String? = nil, env: String? = nil, completion: @escaping (InstallationFile?, (any Error)?) -> Void)Parameters
licenseKeyLicense key.
versionDesired product (app) version, optional. If not provided, the last available version assumed.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
completionInstallation information related to the license if request succeeds, Error if request fails. May be of
LSErrortype. -
Request installation information for the license.
Throws
Error if request fails. May be ofLSErrortype.Declaration
Swift
@objc func requestInstallationFile(user: String, version: String? = nil, env: String? = nil) throws -> InstallationFileParameters
userLicense user name, usually email in lowercase.
versionDesired product (app) version, optional. If not provided, the last available version assumed.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
Return Value
Installation information related to the license.
-
Request installation information for the license.
Declaration
Swift
@objc func requestInstallationFile(user: String, version: String? = nil, env: String? = nil, completion: @escaping (InstallationFile?, (any Error)?) -> Void)Parameters
userLicense user name, usually email in lowercase.
versionDesired product (app) version, optional. If not provided, the last available version assumed.
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
completionInstallation information related to the license if request succeeds, Error if request fails. May be of
LSErrortype. -
Request information about the product from LicenseSpring platform.
Throws
Error if request fails. May be ofLSErrortype.Note
In offline mode data will be retrieved from license file if present.Declaration
Swift
@objc func requestProductDetails(env: String? = nil) throws -> ProductDetailsParameters
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
Return Value
Product details.
-
Request information about the product from LicenseSpring platform.
Note
In offline mode data will be retrieved from license file if present.Declaration
Swift
@objc func requestProductDetails(env: String? = nil, completion: @escaping (ProductDetails?, (any Error)?) -> Void)Parameters
envEnvironment identifier, e.g. “win”, “win32”, “win64”, “mac”, “linux”, “linux32”, “linux64”
completionProduct details if request succeeds, Error if request fails. May be of
LSErrortype. -
Request all the license users on every order by some customer.
Throws
Error if request fails. May be of
LSErrortype.Note
More at /api/v4/customer_license_users
Declaration
Swift
@objc func requestLicenseUsers(for customerEmail: String) throws -> [User]Return Value
Array of the users related to the customer.
-
Request all the license users on every order by some customer.
Note
More at /api/v4/customer_license_users
Declaration
Swift
@objc func requestLicenseUsers(for customerEmail: String, completion: @escaping ([User]?, (any Error)?) -> Void)Parameters
completionArray of the users related to the customer if request succeeds, Error if request fails. May be of
LSErrortype. -
Change password for user based license.
Throws
Error if request fails. May be of
LSErrortype.Note
More at /api/v4/change_password
Declaration
Swift
@objc func changePassword(user: String, password: String, newPassword: String) throwsParameters
userUser email.
passwordCurrent user password.
newPasswordNew user password.
-
Change password for user based license.
Note
More at /api/v4/change_password
Declaration
Swift
@objc func changePassword(user: String, password: String, newPassword: String, completion: @escaping ((any Error)?) -> Void)Parameters
userUser email.
passwordCurrent user password.
newPasswordNew user password.
completionError if request fails. May be of
LSErrortype. -
Helper method to check connection to the LicenseSpring platform.
Declaration
Swift
@objc func checkConnection() -> BoolReturn Value
trueif SDK is able to connect to the LicenseSpring platform andfalseotherwise. -
Helper method to check connection to the LicenseSpring platform.
Declaration
Swift
@objc func checkConnection(completion: @escaping (Bool) -> Void)Parameters
completiontrueif SDK is able to connect to the LicenseSpring platform andfalseotherwise -
Remove license file and internal SDK files if any of them exist.
Note
Typically should be called after license deactivation in the app uninstaller.Throws
Error if clearing fails.Declaration
Swift
@objc func clearLocalStorage() throws -
Gets the users licences using user and password
Declaration
Swift
@objc func getUserLicenses(user: String, password: String) throws -> [UserLicensesData]Parameters
userUser ID, typically email in lowercase.
passwordUser’s password.
Return Value
Array of UserLicensesData
-
Gets the users licences using user and password
Declaration
Swift
@objc func getUserLicenses(user: String, password: String, completion: @escaping ([UserLicensesData]?, (any Error)?) -> Void)Parameters
userUser ID, typically email in lowercase.
passwordUser’s password.
completionArray of UserLicensesData, Error if request fails. May be of
LSErrortype. -
Version of LicenseSpring SDK
Declaration
Swift
@objc static let sdkVersion: String -
Version of LicenseSpring API
Declaration
Swift
@objc static let apiVersion: Int -
Extract SSO license token from URL.
Throws
Error ifurlStringhas invalid format or scheme mismatched.Declaration
Swift
@objc static func extractSSOToken(from urlString: String, scheme: String) throws -> StringParameters
schemeExpected URL scheme to ensure URL is valid. If scheme mismatched, the error is thrown.
Return Value
SSO token to activate the license.